<?php

/**
 * @author      : PhuongTN
 * @version     : 2012
 * @copyright   : FO
 * @name        : hethao_modules_block_business_block_metadata_layout
 * @todo        : Format data for layout
 */
class Fpt_Business_Block_block_metadata_block
{
    /**
     *
     * @var int
     */
    private $BlockID = 0;
    private $BlockName = '';
    private $BlockTitle = '';
    private $BlockDesc = '';
    private $BlockModule = '';
    private $BlockController = '';
    private $BlockAction = '';
    private $BlockParams = '';
    private $CreateDate = 0;
    private $ModifyDate = 0;
    private $Status = 0;
    /**
     * 
     *  `BlockID` int(11) NOT NULL AUTO_INCREMENT,
  `BlockName` varchar(100) DEFAULT NULL COMMENT 'safename',
  `BlockTitle` varchar(100) DEFAULT NULL COMMENT 'ten layout',
  `BlockDesc` varchar(100) DEFAULT NULL,
  `BlockModule` varchar(50) DEFAULT NULL COMMENT 'module to get content',
  `BlockController` varchar(50) DEFAULT 'Block' COMMENT 'controller to get content',
  `BlockAction` varchar(100) DEFAULT NULL COMMENT 'action to get content',
  `BlockParams` varchar(255) DEFAULT NULL COMMENT 'default params',
  `CreateDate` int(11) NOT NULL,
  `ModifyDate` int(11) NOT NULL,
  `Status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '1:active, 0:deleted', 
     * 
     */

    public function __construct()
    {
        $this->BlockID = 0;
        $this->BlockName = '';
        $this->BlockTitle = '';
        $this->BlockDesc = '';
        $this->BlockModule = '';
        $this->BlockController = '';
        $this->BlockAction = '';
        $this->BlockParams = '';
        $this->CreateDate = 0;
        $this->ModifyDate = 0;
        $this->Status = 0;
    }

    public function __destruct()
    {
        unset($this->BlockID, $this->BlockName, $this->BlockTitle, $this->BlockDesc,
              $this->BlockModule, $this->BlockController, $this->BlockAction, $this->BlockParams,
              $this->CreateDate, $this->Status, $this->ModifyDate );
    }

    /**
     * Init data
     * @param array $entity (SectionName,SectionTitle,CreateDate,ModifyDate,LayoutName,Status)
     * @return  Fpt_Business_Block_block_metadata_layout
     */
    public function init($entity)
    {
        if(isset($entity['BlockID']))
        {
            $this->BlockID     = intval($entity['BlockID']);
        }
        $this->BlockTitle  = isset($entity['BlockTitle'])?$entity['BlockTitle']:'';
        $this->BlockName = isset($entity['BlockName'])?Fpt_Global::covertVN($entity['BlockName']):'';
        $this->BlockDesc  = isset($entity['BlockDesc'])?$entity['BlockDesc']:'';
        $this->BlockModule  = isset($entity['BlockModule'])?$entity['BlockModule']:'';
        $this->BlockController  = isset($entity['BlockController'])?$entity['BlockController']:'';
        $this->BlockAction  = isset($entity['BlockAction'])?$entity['BlockAction']:'';
        $this->BlockParams  = isset($entity['BlockParams'])?Zend_Json::encode($entity['BlockParams']):'';
        $this->CreateDate = isset($entity['CreateDate'])?intval($entity['CreateDate']):0;
        $this->ModifyDate = isset($entity['ModifyDate'])?intval($entity['ModifyDate']):0;
        $this->Status   = isset($entity['Status'])?intval($entity['Status']):0;
        return $this;
    }

    /**
     * Format data
     * @return array 
     */
    public function getData()
    {

        return array(
            'BlockID'       => $this->BlockID,
            'BlockName'     => $this->BlockName,
            'BlockTitle'    => $this->BlockTitle,
            'BlockDesc'     => $this->BlockDesc,
            'BlockModule'   => $this->BlockModule,
            'BlockController'  => $this->BlockController,
            'BlockAction'      => $this->BlockAction,
            'BlockParams'      => $this->BlockParams,
            'CreateDate'    => $this->CreateDate,
            'ModifyDate'    => $this->ModifyDate,
            'Status'        => $this->Status,
        );
    }
    /**
     * 
     * @return type 
     */
    public function getDataCache()
    {
        return array(
            'BlockName'    => $this->BlockName,
            'BlockTitle'   => $this->BlockTitle,
            'BlockDesc'    => $this->BlockDesc,
            'BlockModule'  => $this->BlockModule,
            'BlockController'  => $this->BlockController,
            'BlockAction'      => $this->BlockAction,
            'BlockParams'      => $this->BlockParams
        );
    }
}